using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Commerce.Common
{
	/// <summary>
	/// Strongly-typed collection for the CouponType class.
	/// </summary>
	[Serializable]
	public partial class CouponTypeCollection : ActiveList<CouponType,CouponTypeCollection> 
	{	   
		public CouponTypeCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the CSK_CouponTypes table.
	/// </summary>
	[Serializable]
	public partial class CouponType : ActiveRecord<CouponType>, IActiveRecord
	{
		#region .ctors and Default Settings
		
		public CouponType()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public CouponType(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

        
		public CouponType(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public CouponType(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor	
		public static Query CreateQuery() { return new Query(Schema); }

		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("CSK_CouponTypes", TableType.Table, DataService.GetInstance("dashCommerce"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarCouponTypeId = new TableSchema.TableColumn(schema);
				colvarCouponTypeId.ColumnName = "CouponTypeId";
				colvarCouponTypeId.DataType = DbType.Int32;
				colvarCouponTypeId.MaxLength = 0;
				colvarCouponTypeId.AutoIncrement = true;
				colvarCouponTypeId.IsNullable = false;
				colvarCouponTypeId.IsPrimaryKey = true;
				colvarCouponTypeId.IsForeignKey = false;
				colvarCouponTypeId.IsReadOnly = false;
				colvarCouponTypeId.DefaultSetting = @"";
				colvarCouponTypeId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCouponTypeId);
				
				TableSchema.TableColumn colvarDescription = new TableSchema.TableColumn(schema);
				colvarDescription.ColumnName = "Description";
				colvarDescription.DataType = DbType.String;
				colvarDescription.MaxLength = 128;
				colvarDescription.AutoIncrement = false;
				colvarDescription.IsNullable = false;
				colvarDescription.IsPrimaryKey = false;
				colvarDescription.IsForeignKey = false;
				colvarDescription.IsReadOnly = false;
				colvarDescription.DefaultSetting = @"";
				colvarDescription.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDescription);
				
				TableSchema.TableColumn colvarProcessingClassName = new TableSchema.TableColumn(schema);
				colvarProcessingClassName.ColumnName = "ProcessingClassName";
				colvarProcessingClassName.DataType = DbType.String;
				colvarProcessingClassName.MaxLength = 256;
				colvarProcessingClassName.AutoIncrement = false;
				colvarProcessingClassName.IsNullable = false;
				colvarProcessingClassName.IsPrimaryKey = false;
				colvarProcessingClassName.IsForeignKey = false;
				colvarProcessingClassName.IsReadOnly = false;
				colvarProcessingClassName.DefaultSetting = @"";
				colvarProcessingClassName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarProcessingClassName);
				
				TableSchema.TableColumn colvarIsAspClass = new TableSchema.TableColumn(schema);
				colvarIsAspClass.ColumnName = "IsAspClass";
				colvarIsAspClass.DataType = DbType.Boolean;
				colvarIsAspClass.MaxLength = 0;
				colvarIsAspClass.AutoIncrement = false;
				colvarIsAspClass.IsNullable = false;
				colvarIsAspClass.IsPrimaryKey = false;
				colvarIsAspClass.IsForeignKey = false;
				colvarIsAspClass.IsReadOnly = false;
				
						colvarIsAspClass.DefaultSetting = @"((0))";
				colvarIsAspClass.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsAspClass);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["dashCommerce"].AddSchema("CSK_CouponTypes",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("CouponTypeId")]
		public int CouponTypeId 
		{
			get { return GetColumnValue<int>(Columns.CouponTypeId); }

			set { SetColumnValue(Columns.CouponTypeId, value); }

		}

		  
		[XmlAttribute("Description")]
		public string Description 
		{
			get { return GetColumnValue<string>(Columns.Description); }

			set { SetColumnValue(Columns.Description, value); }

		}

		  
		[XmlAttribute("ProcessingClassName")]
		public string ProcessingClassName 
		{
			get { return GetColumnValue<string>(Columns.ProcessingClassName); }

			set { SetColumnValue(Columns.ProcessingClassName, value); }

		}

		  
		[XmlAttribute("IsAspClass")]
		public bool IsAspClass 
		{
			get { return GetColumnValue<bool>(Columns.IsAspClass); }

			set { SetColumnValue(Columns.IsAspClass, value); }

		}

		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
        
        
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(string varDescription,string varProcessingClassName,bool varIsAspClass)
		{
			CouponType item = new CouponType();
			
			item.Description = varDescription;
			
			item.ProcessingClassName = varProcessingClassName;
			
			item.IsAspClass = varIsAspClass;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varCouponTypeId,string varDescription,string varProcessingClassName,bool varIsAspClass)
		{
			CouponType item = new CouponType();
			
				item.CouponTypeId = varCouponTypeId;
			
				item.Description = varDescription;
			
				item.ProcessingClassName = varProcessingClassName;
			
				item.IsAspClass = varIsAspClass;
			
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
        
        
        
        #region Typed Columns
        
        
        public static TableSchema.TableColumn CouponTypeIdColumn
        {
            get { return Schema.Columns[0]; }

        }

        
        
        
        public static TableSchema.TableColumn DescriptionColumn
        {
            get { return Schema.Columns[1]; }

        }

        
        
        
        public static TableSchema.TableColumn ProcessingClassNameColumn
        {
            get { return Schema.Columns[2]; }

        }

        
        
        
        public static TableSchema.TableColumn IsAspClassColumn
        {
            get { return Schema.Columns[3]; }

        }

        
        
        
        #endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string CouponTypeId = @"CouponTypeId";
			 public static string Description = @"Description";
			 public static string ProcessingClassName = @"ProcessingClassName";
			 public static string IsAspClass = @"IsAspClass";
						
		}

		#endregion
		
		
		
	}

}

